const express = require('express')
const router = express.Router()
const multer = require("multer")

const user_handler = require('../router_handler/info')
// 上传图片的方法
const storage = multer.diskStorage({
    // 存储位置 
    destination: function (req, file, callback) {
        // 参数解释 param1:错误信息  param2:上传图片的服务端保存路径，注意这里的路径写法
        // callback(null, "C:/Users/h'y/Desktop/myblog/public/imgs")
        callback(null,'./public/imgs')
    },
    // 确定文件名,在这儿采用了时间戳和图片文件原名为上传的图片文件命名，可以保证名字不重复
    filename: function (req, file, cb) {
        cb(null, `${Date.now()}-${file.originalname}`)
    }
})
// 上传视频的方法
const storage2 = multer.diskStorage({
    // 存储位置 
    destination: function (req, file, callback) {
        // 参数解释 param1:错误信息  param2:上传图片的服务端保存路径，注意这里的路径写法
        // callback(null, "C:/Users/h'y/Desktop/myblog/public/imgs")
        callback(null,'./public/videos')
    },
    // 确定文件名,在这儿采用了时间戳和图片文件原名为上传的图片文件命名，可以保证名字不重复
    filename: function (req, file, cb) {
        cb(null, `${Date.now()}-${file.originalname}`)
    }
})
const upload = multer({ storage: storage })
const upload2 = multer({ storage: storage2 })

router.get('/reware',user_handler.reware)
router.get('/lovetotal',user_handler.loveTotle)
router.post('/addlovenum',user_handler.addLoveNum)
router.get('/loveimgs',user_handler.loveImgs)
router.post('/uploadimgs',upload.array("img", 1),user_handler.uploadImg)
router.post('/deleteimg',user_handler.deleteImg)
router.post('/uploadvideo',upload2.array("video", 1), user_handler.uploadVideo)
router.get('/lovevideos', user_handler.loveVideo)
router.post('/deletevideo',user_handler.deleteVideo)
router.post('/uploadmessage_lyb',user_handler.uploadMessage_lyb)
router.get('/message_lyb', user_handler.Message_lyb)
router.post('/uploadmessage_gyw',user_handler.uploadMessage_gyw)
router.get('/message_gyw', user_handler.Message_gyw)
router.post('/deleteMessage_lyb',user_handler.deleteMessage_lyb)
router.post("/deleteMessage_gyw",user_handler.deleteMessage_gyw)
router.post("/uploadOnineWrite",user_handler.uploadOnineWrite)
router.get("/reqGet_o_Writes",user_handler.reqGet_o_Writes)
router.post("/reqGet_o_Inf",user_handler.reqGet_o_Inf)
router.post("/delete_o_Write",user_handler.delete_o_Write)

module.exports = router